<template>
  <div>
    <el-table
      :data="seckillList"
      style="width: 100%"
      row-key="id"
      border
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column prop="title" label="活动名称"> </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <div>
            <el-button type="info" v-if="scope.row.status==1">启用</el-button>
            <el-button type="warning" v-else>禁用</el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <div>
            <el-button type="success" @click="bianji(scope.row.id)">编辑</el-button>
            <v-del @del="del(scope.row.id)"></v-del>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>


<script>
import {mapActions,mapGetters} from 'vuex'
import {seckdelete} from '../../../request/api'
import { successAlert, warningAlert } from "../../../util/alert.js";
export default {
  data() {
    return {
    };
  },
  methods:{
    ...mapActions({
      reqseckillList:'seckill/reqchangelist'
    }),
    // 点击删除
    del(id){
      seckdelete({id:id}).then(res=>{
        if (res.data.code == 200) {
          // 成功的弹窗
          successAlert(res.data.msg);
          // 重新请求列表数据
          this.reqseckillList()
        } else {
          // 失败的弹窗
          warningAlert(res.data.msg);
        }
      })
    },
    // 点击编辑
    bianji(id){
      this.$emit('bianji',id)
    }
  },
  computed:{
    ...mapGetters({
      seckillList:'seckill/list'
    })
  },
  mounted() {
    this.reqseckillList()
  },
};
</script>

<style>
</style>